<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>5.继续加深印象</title>
</head>
<body>
	<canvas id="canvas"></canvas>
	<script type="x-shader/x-vertex" id="vertex">
		attribute vec4 a_position;
		
		void main(){
			gl_Position = a_position;
		}
	</script>
	<script type="x-shader/x-fragment" id="fragment">
		precision mediump float;
		void main(){
			gl_FragColor = vec4(1.0,0.0,1.0,1.0);;
		}
	</script>
	<script src="https://webglfundamentals.org/webgl/resources/webgl-utils.js"></script>
	<script src="https://webglfundamentals.org/webgl/resources/m4.js"></script>
	<script src="https://webglfundamentals.org/webgl/resources/primitives.js"></script>
	<script src="https://webglfundamentals.org/webgl/resources/texture-utils.js"></script>
	<script src="https://webglfundamentals.org/webgl/resources/chroma.min.js"></script>
	<script>
		/** @type {HTMLCanvasElement} */   
		const canvas=document.getElementById("canvas");
		canvas.width=window.innerWidth
		canvas.height=window.innerHeight
		const gl=canvas.getContext("webgl")
		gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);

		const programInfo=webglUtils.createProgramInfo(gl,["vertex","fragment"])
		gl.useProgram(programInfo.program)

		const position=new Float32Array([
			-1,1,
			1,1,
			1,-1
		])
		const a_position=gl.getAttribLocation(programInfo.program,"a_position")
		const buffer=gl.createBuffer()
		gl.bindBuffer(gl.ARRAY_BUFFER,buffer)
  		gl.bufferData(gl.ARRAY_BUFFER, position, gl.STATIC_DRAW);
		gl.enableVertexAttribArray(a_position)
		gl.vertexAttribPointer(a_position,2,gl.FLOAT,false,0,0)

		gl.drawArrays(gl.TRIANGLES,0,3)
	</script>
</body>
</html>